package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttribute;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpSession;

/**
 * 跳转页面的方式
 * @author zjw
 * @description
 * @date 2021/10/8$ 14:53$
 */
@Controller
@RequestMapping("/jump")
@SessionAttributes(value = {"age"})
public class JumpController {

    /**
     * 返回String，正常情况下为转发页面
     * @return
     */
    @RequestMapping("/string")
    public String string(){
        return "/test.jsp";
    }


    /**
     * 返回String，重定向
     * @return
     */
    @RequestMapping("/redirect-test")
    public String redirectTest(){
        return "redirect:/xxx";
    }

    /**
     * 返回String，重定向
     * @return
     */
    @RequestMapping("/redirect-baidu")
    public String redirectBaidu(){
        return "redirect:http://www.baidu.com";
    }

    /**
     * 返回String，向Request域传值
     * @return
     */
    @RequestMapping("/passvalue-model")
    public String passvalueModel(Model model){
        model.addAttribute("age","24");
        return "/test.jsp";
    }


    /**
     * 返回String，向Session域传值
     * @return
     */
    @RequestMapping("/passvalue-session")
    public String passvalueSession(Model model){
        model.addAttribute("age","24");
        return "/test.jsp";
    }

}
